//
//  fGMainTabBarViewController.m
//  fGeekApp
//
//  Created by Administrator on 15/3/6.
//  Copyright (c) 2015年 cwx. All rights reserved.
//+--------------------------------------------
// MainTabBarController：负责三个"storyBoard"的合并
//+--------------------------------------------

#import "fGMainTabBarViewController.h"

@interface fGMainTabBarViewController ()

@end

@implementation fGMainTabBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setTabBar];
    
}

/**
 *初始化tabBar
 */
-(void)setTabBar{
    //设置tabbar的title字体选中时颜色
    UITabBarItem *tabBar = [UITabBarItem appearance];
    [tabBar setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor redColor]} forState:UIControlStateSelected];
    
    //模式tabbar图标选中时的描边颜色
    [self.tabBar setTintColor:[UIColor orangeColor]];
    
    //向Tabbar中添加第一个页面
    UIStoryboard *homeStoryBoard = [UIStoryboard storyboardWithName:@"Home" bundle:nil];
    //获取storyboard的初始页面
    UIViewController *homeVC = [homeStoryBoard instantiateInitialViewController];
    [self setUpAllChildViewController:homeVC andTitle:@"首页" andImage:@"tabbar_home@2x"];
    
    //向Tabbar中添加第二个页面
    UIStoryboard *bussinessStoryBoard = [UIStoryboard storyboardWithName:@"Bussiness" bundle:nil];
    //获取storyboard的初始页面
    UIViewController *bussinessVC = [bussinessStoryBoard instantiateInitialViewController];
    [self setUpAllChildViewController:bussinessVC andTitle:@"商家" andImage:@"tabbar_bussiness@2x"];
    
    
    //向Tabbar中添加第三个页面
    UIStoryboard *personalStoryBoard = [UIStoryboard storyboardWithName:@"Personal" bundle:nil];
    //获取storyboard的初始页面
    UIViewController *personalVC = [personalStoryBoard instantiateInitialViewController];
    [self setUpAllChildViewController:personalVC andTitle:@"我的" andImage:@"tabbar_personal@2x"];
    
    //设置TabBar默认显示页面（不设置默认为0）
    self.selectedIndex = 0;
}

/**
 *初始化所有的子控制器
 */
-(void)setUpAllChildViewController:(UIViewController *)vc andTitle:(NSString *)title andImage:(NSString *)imageName{
    
    vc.tabBarItem.title = title;
    vc.tabBarItem.image = [UIImage imageNamed:imageName];
    [self addChildViewController:vc];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
